package top.wshape1.rpc.compress;

import top.wshape1.rpc.common.extension.ExtensionLoader;
import top.wshape1.rpc.config.JJRpcConfig;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2024-02-20
 */

public class CompressorFactory {

    private static final ExtensionLoader<Compressor> loader = ExtensionLoader.getExtensionLoader(Compressor.class);

    private static Compressor compressor;

    public static Compressor getCompressor() {
        if (compressor == null) {
            compressor = loader.getExtension(JJRpcConfig.CONFIG.getCompress().getCompressor());
        }
        return compressor;
    }

    public static void setCompressor(Compressor customCompressor) {
        compressor = customCompressor;
    }


}
